projects
/
project
/
ubus.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
041c9d1
)
lua: avoid truncation of large numeric values
author
Alin Nastac
<
[email protected]
>
Mon, 3 Feb 2020 12:58:04 +0000
(13:58 +0100)
committer
Petr Štetiar
<
[email protected]
>
Thu, 3 Jun 2021 08:00:50 +0000
(10:00 +0200)
If the Lua number exceeds the maximum value representable by an
unsigned 32bit integer, store it in an unsigned 64bit integer
field instead.
Signed-off-by: Alin Nastac <
[email protected]
>
[align code style, reword commit message]
Signed-off-by: Jo-Philipp Wich <
[email protected]
>
(cherry picked from commit
171469e3138cce191892e20b6fd35b52c9368064
)
lua/ubus.c
patch
|
blob
|
history
diff --git
a/lua/ubus.c
b/lua/ubus.c
index 86dcc5007b3a2776a611bf6c0a9255b7c5d0b946..e2bb0817fc8eda0b24aabb0a31801c224b8e3f29 100644
(file)
--- a/
lua/ubus.c
+++ b/
lua/ubus.c
@@
-196,7
+196,10
@@
ubus_lua_format_blob(lua_State *L, struct blob_buf *b, bool table)
case LUA_TINT:
#endif
case LUA_TNUMBER:
- blobmsg_add_u32(b, key, (uint32_t)lua_tointeger(L, -1));
+ if ((uint64_t)lua_tonumber(L, -1) > INT_MAX)
+ blobmsg_add_u64(b, key, (uint64_t)lua_tonumber(L, -1));
+ else
+ blobmsg_add_u32(b, key, (uint32_t)lua_tointeger(L, -1));
break;
case LUA_TSTRING: